from dataclasses import dataclass


# 悬挂系统
@dataclass()
class Suspension:
    # 减震
    damping: str
    # 转向
    steering: str


# 发动机
@dataclass()
class Engine:
    # 气缸数量
    cylinder: int
    # 发动机排量
    displacement: int
    # 是否带涡轮蒸鸭
    have_turbine: bool


# 变速箱
@dataclass()
class Gearbox:
    #变速箱档位数
    number_of_gears: int

    # 离合器类型
    clutch_type: str


@dataclass(order=False)
class Car:
    make: str
    model: str
    year: str
    suspension: Suspension
    engine: Engine
    gearbox: Gearbox
    odometer: int = 0

    def set_odometer(self, odometer):
        self.odometer = odometer

    def driver(self, a):
        self.odometer += a


def product_panamera():
    # 组合，可以将一个类里面的一部分东西抽取出来
    # 将大任务拆解为小任务，降低开发复杂度
    suspension = Suspension('空气悬挂', '电子助力转向')
    engine = Engine(8, 4.2, True)
    gearbox = Gearbox(8, 'AT')
    return Car('保时捷', '帕拉梅拉', '2023', suspension, engine, gearbox)


if __name__ == '__main__':
    car = product_panamera()
    print(car)

    car.driver(200)
    print(car)
